<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据插入</title>
    <script src="jquery-1.11.3.min.js"></script>
    <script src="cardata.js"></script>
    <script>

        // todo 请求的数据插入到数据库中

        function insert( brand ){
            var url = 'insert.php';
            var data = {
                brand : brand
            };
            $.post(url, data, function( json ){

            });
        }

        var l = carData.length;
        console.log(l);
        var pointer = 0;
        function checkData(){

            if( pointer >= l ){
                return;
            }
//            if( pointer > 1){
//                return ;
//            }
            setTimeout(function(){
                console.log('brand_id:' + carData[pointer].brandid );
                if( carData[pointer].brandid == 140 ){
                    insert( JSON.stringify(carData[pointer]) );
                }

                pointer ++;
                checkData();
            },200);


        }
        checkData();

    </script>
</head>
<body>

</body>
</html>